﻿@*@model ShiXuLong.Model.Shop*@
@{
    Layout = null;
}

<!DOCTYPE html>

<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <title>AddView</title>
    
    <link href="~/lib/layui-v2.5.6/layui/css/layui.css" rel="stylesheet" />
    <script src="~/lib/layui-v2.5.6/layui/layui.js"></script>
    <script src="~/scripts/jquery-3.5.1.js"></script>
</head>
<body>

    <form class="layui-form" id="frmAdd">
        <div class="layui-form-item">
            <label class="layui-form-label">商品编号</label>
            <div class="layui-input-inline">
                <input type="text" name="ShopId" required lay-verify="required" placeholder="请输入标题" autocomplete="off" class="layui-input">
            </div>
        </div>
        @* 按照特殊的规则生成 *@
        <div class="layui-form-item">
            <label class="layui-form-label">商品名称</label>
            <div class="layui-input-inline">
                <input type="text" name="ShopName" required lay-verify="required" placeholder="请输入标题" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item layui-form-text">
            <label class="layui-form-label">文本域</label>
            <div class="layui-input-inline">
                <textarea name="ProductProfile" placeholder="请输入内容" class="layui-textarea"></textarea>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">商品类别</label>
            <div class="layui-input-inline">
                <select name="ShopTypeId" lay-verify="required">
                    @foreach (var item in ViewBag.ShopType)
                    {
                        <option value="@item.Id">@item.ShopTypeName</option>
                    }
                    @*<option value="1">花花公子</option>
                    <option value="2">南极人</option>
                    <option value="3">特步</option>
                    <option value="6">361</option>*@
                </select>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">状态</label>
            <div class="layui-input-inline">
                <select name="Status" lay-verify="required">
                    <option value="0">下架</option>
                    <option value="1">上架</option>
                </select>
            </div>
        </div>
        @*<div class="layui-form-item">
            <label class="layui-form-label">推荐位置</label>
            <div class="layui-input-inline">
                <select name="RecommendId" lay-verify="required">
                    <option value=""></option>
                    <option value="0">1</option>
                </select>
            </div>
        </div>*@
        <div class="layui-form-item">
            <label class="layui-form-label">Display</label>
            <div class="layui-input-inline">
                <input type="text" name="Shopimage" required lay-verify="required" placeholder="请输入标题" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">商品图片</label>
            <div class="layui-input-inline">
                <input type="text" name="Shopimage" required lay-verify="required" placeholder="请输入标题" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">价格</label>
            <div class="layui-input-inline">
                <input type="text" name="Price" required lay-verify="required" placeholder="请输入标题" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">库存数量</label>
            <div class="layui-input-inline">
                <input type="text" name="Number" required lay-verify="required" placeholder="请输入标题" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">规格</label>
            <div class="layui-input-inline">
                <input type="text" name="GuideId" required lay-verify="required" placeholder="请输入标题" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-input-block">
                <button class="layui-btn" id="AddBtn" lay-filter="formDemo">添加到数据库</button>
                <button type="reset" class="layui-btn layui-btn-primary">重置</button>
            </div>
        </div>
    </form>

    <script>
        //Demo
        layui.use(['form', 'layer'], function () {
            var form = layui.form;
            var layer = layui.layer;
            var $ = layui.$;

            $("#AddBtn").click(function () {
                var con = $("#frmAdd").serialize();
                console.log(1232);
                $.ajax({
                    url: "/Home/Add",
                    type: "post",
                    data: con,
                    success: function (re) {
                        if (re.success > 0) {
                            layer.msg("添加商品成功");
                            setTimeout(function () {
                                var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
                                parent.layer.close(index); //再执行关闭
                            }, 500);
                        } else {
                            layer.msg("添加商品失败");
                        }
                    }
                });

                return false;


            });




        });
    </script>

</body>
</html>
